import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-07-17
 * Time: 9:35
 */
public class Test {
    /*    public static void swap(char[] ch ,int left, int right){
            char tmp = '\u0000';
            while (left < right){
                tmp = ch[left];
                ch[left] = ch[right];
                ch[right] = tmp;
                left++;
                right--;
            }
        }

        public static String reverseSentence(String str) {

            char ch[] = str.toCharArray();
            int left = 0;
            int right = str.length()-1;
            int cur = 0;
            swap(ch,left,right);//逆置整个数组
            while(cur != str.length()-1) {
                int start = cur;
                while(ch[cur] != ' ') {//找到每个单词
                    cur++;
                }
                swap(ch,start,cur-1);//逆置每个单词
                if(ch[cur] == ' ') {
                    cur++;
                }
            }
            return String.copyValueOf(ch);
        }

        public  static  void reverse (char c[],int i,int j){
            while (i<j){
                char tmp=c[i];
                c[i]=c[j];
                c[j]=tmp;
                i++;
                j--;
            }
        }
        public  static  String reverseStr(String s){
            //去除字符串开头的空格
            s= s.trim();
            //1、整体逆序
            //先转换整数组
            char []c=  s.toCharArray();
            reverse(c,0,c.length-1);
            //2、每个单词逆序
            int start=0;
            for (int i = 0; i < c.length ; i++) {
                //当i自己是空格的时候，就说明她前面的是一个整体单词了
                //比如   i am a student    当i走到4下标的时候，am就是一个单词,逆置它
                if(c[i]==' '){
                    reverse(c,start,i-1);
                    start=i+1;
                }
            }
            return String.valueOf(c);
        }*/
    public static void reverse(char c[], int i, int j) {
        while (i < j) {
            char tmp = c[i];
            c[i] = c[j];
            c[j] = tmp;
            i++;
            j--;
        }
    }

    public static String reverseStr(String s) {
        s = s.trim();
        char[] c = s.toCharArray();
        reverse(c, 0, c.length - 1);
        int start = 0;
        for (int i = 0; i < c.length; i++) {
            if (c[i] == ' ') {
                reverse(c, start, i - 1);
                start = i + 1;
            }
        }
        return String.valueOf(c);
    }

    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String string2 = scanner.nextLine();
        System.out.println(reverseStr(string2));
    }


    public static void main2(String[] args) {
        String str = "aabbccdddf";
        String ret = test4(str);
        System.out.println(ret);
    }
    public static String test4(String str) {
        StringBuilder stringBuilder = new StringBuilder();
        char[] chars = str.toCharArray();
        char char1 = str.charAt(0);
        int count = 1;
        for (int i = 1; i < chars.length; i++) {
            if  (char1 == str.charAt(i)) {
                count++;
                continue;
            }
            stringBuilder = stringBuilder.append(char1).append(count);
            count = 1;
            char1=str.charAt(i);
        }
        stringBuilder = stringBuilder.append(char1).append(count);
        return stringBuilder.toString();
    }



    public static void main4(String[] args) {
        String str = "abcd123456ef1g";
        int ret = isNumeric(str);
        System.out.println(ret);
    }

    public static int isNumeric(String str){
        char[] ch = str.toCharArray();
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            if(ch[i] >= '0' && ch[i] <= '9'){
                count++;
            }
        }
        return count;
    }


    public static void main(String[] args) {
        String str = "AEDsdHJ";
        System.out.println(mtoLowerCase(str));
    }
    public static String mtoLowerCase(String s) {
        if(s == null || s.length() == 0) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        for(int i = 0;i < s.length();i++) {
            char ch = s.charAt(i);
            //大写字母进行转换
            if(ch >= 'A' && ch <= 'Z') {
                sb.append((char)(ch+32));
            }else{
                //小写字母直接拼接
                sb.append(ch);
            }
        }
        return sb.toString();
    }
}
